// src/stores/counterStore.js
import { defineStore } from 'pinia'

export const useUserInfoStore = defineStore('userInfo', {
  state: () => ({
        // 用户菜单
        nav:[],
        // 用户昵称
        nickName:'',
        // 用户权限表达式集合
        permission:[]
  }),
  actions: {
    setNav(data){
      this.nav = data
    },
    setnickName(name){
      this.name = name
    },
    setPermission(ps){
      this.permission = ps
    },
    /**
     * 判断用户是否有指定的权限表达式
     * @param requiredPermission {string} 需要验证的权限表达式
     * @returns {boolean}
     */
    hasPermission(requiredPermission) {
      return this.permission.includes(requiredPermission)
    }
  }
})